widget-factory: Add a listbox example
authorMatthias Clasen <mclasen@redhat.com>
Sun, 13 Apr 2014 04:45:30 +0000 (21:45 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 13 Apr 2014 04:45:30 +0000 (21:45 -0700)
demos/widget-factory/widget-factory.c
demos/widget-factory/widget-factory.ui

index 19380a3a87a7dbaf3db62d7e841c8bf3116b5c65..21ff514268d2413f3cc6e6c0914c4a07a29af777 100644 (file)
@@ -220,6 +220,22 @@ startup (GApplication *app)
   g_object_unref (builder);
 }
 
+static void
+update_header (GtkListBoxRow *row,
+               GtkListBoxRow *before,
+               gpointer       data)
+{
+  if (before != NULL &&
+      gtk_list_box_row_get_header (row) == NULL)
+    {
+      GtkWidget *separator;
+
+      separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      gtk_widget_show (separator);
+      gtk_list_box_row_set_header (row, separator);
+    }
+}
+
 static void
 activate (GApplication *app)
 {
@@ -255,6 +271,9 @@ activate (GApplication *app)
   adj = (GtkAdjustment *) gtk_builder_get_object (builder, "adjustment2");
   g_signal_connect (adj, "value-changed", G_CALLBACK (spin_value_changed), widget);
 
+  widget = (GtkWidget *)gtk_builder_get_object (builder, "listbox");
+  gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_header, NULL, NULL);
+
   gtk_widget_show_all (GTK_WIDGET (window));
 
   g_object_unref (builder);
index f33e45fd8683a93e9f417bb9f95808cbaada8170..08aa24653bdec052b072f8e529f8820535ff6077 100644 (file)
       </item>
     </section>
   </menu>
-  <menu id='gear_menu'>
+  <menu id="gear_menu">
     <section>
       <item>
-        <attribute name='label' translatable='yes'>Dark Theme</attribute>
-        <attribute name='action'>win.dark</attribute>
+        <attribute name="label" translatable="yes">Dark Theme</attribute>
+        <attribute name="action">win.dark</attribute>
       </item>
     </section>
   </menu>
@@ -1924,6 +1924,88 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
                         <property name="top-attach">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkFrame">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkListBox" id="listbox">
+                            <property name="visible">True</property>
+                            <property name="selection-mode">none</property>
+                            <child>
+                              <object class="GtkBox" id="listboxrow1">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 1</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSwitch">
+                                    <property name="visible">True</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="listboxrow2">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 2</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkScale">
+                                    <property name="orientation">horizontal</property>
+                                    <property name="visible">True</property>
+                                    <property name="margin">6</property>
+                                    <property name="draw-value">False</property>
+                                    <property name="width-request">150</property>
+                                    <property name="adjustment">adjustment1</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="listboxrow3">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 3</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">3</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
               </object>
@@ -1937,4 +2019,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
       </object>
     </child>
   </object>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <widgets>
+      <widget name="listboxrow1"/>
+      <widget name="listboxrow2"/>
+      <widget name="listboxrow3"/>
+    </widgets>
+  </object>
 </interface>